import axios from "axios";

//不带Token的请求（导出的是对象）
export const axios_no_token = axios.create({
    baseURL: "http://localhost:8080/demo",
    headers: {
        "Content-Type":"application/json"
    }
});


//带有Token认证请求（导出的是函数）
export const axiso_with_token = () => {
    //从本地存储中取得之前预存的token字符串
    let token = sessionStorage.getItem("token");
    const instance = axios.create({
        baseURL: "http://localhost:8080/demo",
        headers: {
            "Content-Type":"application/json",
            "token": token
        }
    });
    return instance;
}

export default axiso_with_token;